using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class CategoriesInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			Name,
			NameVN,
			Rank,
			LinkedID,
			Level,
			Status,
			Image,
			Decribes,
			Type
		}
		private Int32 _ID;
		private String _Name;
		private String _NameVN;
		private Int32 _Rank;
		private Int32 _LinkedID;
		private Int32 _Level;
		private Int32 _Status;
		private String _Image;
		private String _Decribes;
		private String _Type;
		
		public Int32 ID{	get{ return _ID;} set{_ID = value;} }
		public String Name{	get{ return _Name;} set{_Name = value;} }
		public String NameVN{	get{ return _NameVN;} set{_NameVN = value;} }
		public Int32 Rank{	get{ return _Rank;} set{_Rank = value;} }
		public Int32 LinkedID{	get{ return _LinkedID;} set{_LinkedID = value;} }
		public Int32 Level{	get{ return _Level;} set{_Level = value;} }
		public Int32 Status{	get{ return _Status;} set{_Status = value;} }
		public String Image{	get{ return _Image;} set{_Image = value;} }
		public String Decribes{	get{ return _Decribes;} set{_Decribes = value;} }
		public String Type{	get{ return _Type;} set{_Type = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public CategoriesInfo()
		{
			_ID = 0;
			_Name = "";
			_NameVN = "";
			_Rank = 0;
			_LinkedID = 0;
			_Level = 0;
			_Status = 0;
			_Image = "";
			_Decribes = "";
			_Type = "";
		}
		public CategoriesInfo(
		Int32 ID,
		String Name,
		String NameVN,
		Int32 Rank,
		Int32 LinkedID,
		Int32 Level,
		Int32 Status,
		String Image,
		String Decribes,
		String Type
		)
		{
			_ID = ID;
			_Name = Name;
			_NameVN = NameVN;
			_Rank = Rank;
			_LinkedID = LinkedID;
			_Level = Level;
			_Status = Status;
			_Image = Image;
			_Decribes = Decribes;
			_Type = Type;
		}
		public CategoriesInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.ID.ToString()]);
				_Name = dr[Field.Name.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Name.ToString()]);
				_NameVN = dr[Field.NameVN.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NameVN.ToString()]);
				_Rank = dr[Field.Rank.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Rank.ToString()]);
				_LinkedID = dr[Field.LinkedID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.LinkedID.ToString()]);
				_Level = dr[Field.Level.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Level.ToString()]);
				_Status = dr[Field.Status.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Status.ToString()]);
				_Image = dr[Field.Image.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Image.ToString()]);
				_Decribes = dr[Field.Decribes.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Decribes.ToString()]);
				_Type = dr[Field.Type.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Type.ToString()]);
			}
		}
		public CategoriesInfo(CategoriesInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_Name = objEntr.Name;			
			_NameVN = objEntr.NameVN;			
			_Rank = objEntr.Rank;			
			_LinkedID = objEntr.LinkedID;			
			_Level = objEntr.Level;			
			_Status = objEntr.Status;			
			_Image = objEntr.Image;			
			_Decribes = objEntr.Decribes;			
			_Type = objEntr.Type;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("Categories");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int32)),
				new DataColumn(Field.Name.ToString(), typeof(String)),
				new DataColumn(Field.NameVN.ToString(), typeof(String)),
				new DataColumn(Field.Rank.ToString(), typeof(Int32)),
				new DataColumn(Field.LinkedID.ToString(), typeof(Int32)),
				new DataColumn(Field.Level.ToString(), typeof(Int32)),
				new DataColumn(Field.Status.ToString(), typeof(Int32)),
				new DataColumn(Field.Image.ToString(), typeof(String)),
				new DataColumn(Field.Decribes.ToString(), typeof(String)),
				new DataColumn(Field.Type.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.Name.ToString()] = _Name;
			row[Field.NameVN.ToString()] = _NameVN;
			row[Field.Rank.ToString()] = _Rank;
			row[Field.LinkedID.ToString()] = _LinkedID;
			row[Field.Level.ToString()] = _Level;
			row[Field.Status.ToString()] = _Status;
			row[Field.Image.ToString()] = _Image;
			row[Field.Decribes.ToString()] = _Decribes;
			row[Field.Type.ToString()] = _Type;
			return row;
		}
        #endregion InitTable
    }
}
